<?php
    /**
    *file-level documentation
    *@author Name <email@exp.com>
    *28 May 2012
    *@copyright Copyright (c) 2012, Tuncay Bakan
    *@package somePackage
    *
    */
    /**
    *
    */
    class Viewmanager{
        private static $oInstance = null;
        private $sTemplatePath;
        private $sLayoutPath;
        private $sContentPath;
        private $sCSSPath;
        private $sTemplateSuffix = '.php';
        private $sLayout;
        private $sCSS;
        
        private $sTitle = '';
        private $sContent = '';
        private $sNavigation = '';
        private $sLeftNavigation ='';
        private $sLeftNavigationTitle = '';
        private $sLocation = '';
        
        private $sLayoutTemplate = '';
        
        private function __construct(){
            $this->sTemplatePath = WEBSITE_ROOT . 'template/';
            $this->sLayoutPath = $this->sTemplatePath . 'layout/';
            $this->sContentPath = $this->sTemplatePath . 'content/';
            $this->sCSSPath = './template/css/';
        }
                
        public static function getInstance(){
            if(self::$oInstance===null){
                self::$oInstance = new self;
            }
            return self::$oInstance;
        }
        
        public function _setLayout($sLayout){
            $this->sLayout = $this->sLayoutPath . $sLayout . '.php';
        }
        
        public function _setCSS($sCSS){
            $this->sCSS = $this->sCSSPath . $sCSS . '.css';
        }
        
        public function load(){
            

            if(file_exists($this->sLayout)){
            include_once($this->sLayout);
            }else{
                ;
            }
        }
        
        public function setSection($sKey, $sValue){
            $sVariable = 's'.$sKey;
            $this->$sVariable = $sValue;
        }
        
        public function getView($sTemplateName){
            $sFullTemplatePath = $this->sContentPath . $sTemplateName . $this->sTemplateSuffix;
            if(file_exists($sFullTemplatePath)){
                return new View($sFullTemplatePath);
            } else{
                $sFullTemplatePath = $this->sTemplatePath . DEFAULT_VIEW . $this->sTemplateSuffix;
                return new View($sFullTemplatePath);
            }
        }
        
    }
?>
